#lang sicp

(define (pascal-triangle n)
  (define (new-line line)
    (define (iter lst line)
      (if (null? line)
          (list lst)
          (let ((a (car line)))
            (cons (+ lst a) (iter a (cdr line))))))
    (iter 0 line))
  
  (if (= n 0)
      '((1))
      (let* ((trg (pascal-triangle (- n 1)))
             (line (car trg)))
        (cons (new-line line) trg))))